package com.example.uploaddemo.controller;

import com.example.uploaddemo.service.ILocalService;
import io.minio.errors.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * @Author: cc
 * @Description: TODO
 * @DateTime: 2022/3/1 10:53
 */
@RestController
@RequestMapping("/minio")
public class LocalController {

    @Autowired
    private ILocalService localService;


    @PostMapping("/upload")
    public String upload(MultipartFile file,String name,String MD5,Integer chunkIndex, Integer chunkTotal) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, XmlParserException, InvalidResponseException, InternalException {

        return localService.upload(file,name,MD5,chunkIndex,chunkTotal);

    }


}
